// 添加 package 声明
package com.imut.onlinebanking.dealings.controller;

import com.imut.onlinebanking.base.response.JsonResult;
import com.imut.onlinebanking.dealings.pojo.vo.TransactionsVO;
import com.imut.onlinebanking.dealings.servicr.impl.TransactionsServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

@RestController
@RequestMapping("/dealings")
@Slf4j
public class TransactionsController {

    @Autowired
    private TransactionsServiceImpl transactionsService;

    /**
     * 根据用户ID查询交易记录
     */
    @GetMapping("/transactions")
    public JsonResult getTransactionsByUserId(@RequestParam Integer userId) {
        System.out.println("请求查询用户的交易记录"+ userId);
        List<TransactionsVO> transactions = transactionsService.findTransactionsByUserId(userId);
        System.out.println("List<TransactionsVO>" + transactions);
        return JsonResult.ok(transactions);
    }
}
